package com.util;

import android.content.res.Resources;
import android.content.res.TypedArray;

/**
 * Created by Alex on 2017/5/26.
 * 用于获取drawable数组中的drawable的id
 */

public class ResUtil
{
    public static int[] getImgIdRes(Resources res,int arrID)
    {
        TypedArray draws;
        draws = res.obtainTypedArray(arrID);
        int n = draws.length();
        int[] drawsID = new int[n];
        for(int i = 0 ; i < n;i ++) {
            drawsID[i] = draws.getResourceId(i, 0);
        }
        return drawsID;
    }

    //将字符转为 数据库属性名
    public static String changeTYPE(String type) {
        System.out.println(type);
        String nt = null;
        switch (type) {
            case "空气温度":
                nt = "airtemp";
                break;
            case "空气湿度":
                nt = "airhumi";
                break;
            case "光照强度":
                nt = "sundata";
                break;
            case "二氧化碳":
                nt = "coo";
                break;
            case "土壤温度":
                nt = "soiltemp";
                break;
            case "土壤湿度1":
                nt = "soilhumi1";
                break;
            case "土壤湿度2":
                nt = "soilhumi2";
                break;
            case "土壤盐分":
                nt = "yanfen";
                break;
            default:
                nt = null;
                break;
        }
        return nt;
    }
}
